1
//--------------------------------------------------------------------------
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // File: TaskFactoryExtensions_ContinueWhenAllAny.cs
7 //--------------------------------------------------------------------------
9 using System
.Collections
.Generic
;
11 namespace System
.Threading
.Tasks
13 public static partial class TaskFactoryExtensions
16 /// Creates a continuation Task that will compplete upon
17 /// the completion of a set of provided Tasks.
19 /// <param name="factory">The TaskFactory to use to create the continuation task.</param>
20 /// <param name="tasks">The array of tasks from which to continue.</param>
21 /// <returns>A task that, when completed, will return the array of completed tasks.</returns>
22 public static Task
<Task
[]> WhenAll(
23 this TaskFactory factory
, params Task
[] tasks
)
25 return factory
.ContinueWhenAll(tasks
, completedTasks
=> completedTasks
);
29 /// Creates a continuation Task that will compplete upon
30 /// the completion of a set of provided Tasks.
32 /// <param name="factory">The TaskFactory to use to create the continuation task.</param>
33 /// <param name="tasks">The array of tasks from which to continue.</param>
34 /// <returns>A task that, when completed, will return the array of completed tasks.</returns>
35 public static Task
<Task
<TAntecedentResult
>[]> WhenAll
<TAntecedentResult
>(
36 this TaskFactory factory
, params Task
<TAntecedentResult
>[] tasks
)
38 return factory
.ContinueWhenAll(tasks
, completedTasks
=> completedTasks
);
42 /// Creates a continuation Task that will complete upon
43 /// the completion of any one of a set of provided Tasks.
45 /// <param name="factory">The TaskFactory to use to create the continuation task.</param>
46 /// <param name="tasks">The array of tasks from which to continue.</param>
47 /// <returns>A task that, when completed, will return the completed task.</returns>
48 public static Task
<Task
> WhenAny(
49 this TaskFactory factory
, params Task
[] tasks
)
51 return factory
.ContinueWhenAny(tasks
, completedTask
=> completedTask
);
55 /// Creates a continuation Task that will complete upon
56 /// the completion of any one of a set of provided Tasks.
58 /// <param name="factory">The TaskFactory to use to create the continuation task.</param>
59 /// <param name="tasks">The array of tasks from which to continue.</param>
60 /// <returns>A task that, when completed, will return the completed task.</returns>
61 public static Task
<Task
<TAntecedentResult
>> WhenAny
<TAntecedentResult
>(
62 this TaskFactory factory
, params Task
<TAntecedentResult
>[] tasks
)
64 return factory
.ContinueWhenAny(tasks
, completedTask
=> completedTask
);